package co.fitstart.mobile.service.impl;

import java.util.List;
import org.springframework.stereotype.Service;
import com.demo2do.core.service.impl.GenericServiceImpl;
import co.fitstart.entity.order.MoyuAddress;
import co.fitstart.entity.order.MoyuOrder;
import co.fitstart.mobile.service.MoyuService;

@Service("moyuService")
public class MoyuServiceImpl extends GenericServiceImpl<MoyuOrder> implements MoyuService {
    
    /*
     * (non-Javadoc)
     * @see co.fitstart.mobile.service.MoyuService#saveOrder(co.fitstart.entity.order.MoyuOrder)
     */
    public void saveOrder(MoyuOrder moyuOrder) {
        
        this.save(moyuOrder);
        
        MoyuAddress moyuAddress = new MoyuAddress(moyuOrder);
        this.save(moyuAddress);
        
    }
    
    /*
     * (non-Javadoc)
     * @see co.fitstart.mobile.service.MoyuService#list(java.lang.String)
     */
    @SuppressWarnings("unchecked")
    public List<MoyuOrder> list(String openid) {
        return genericDaoSupport.searchForList("FROM MoyuOrder WHERE disabled = false AND openid = :openid", "openid", openid);
    }
    
}
